package com.letsiot.applications.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.letsiot.applications.entity.SysPermissionResources;
import com.letsiot.applications.repository.SysPermissionResourcesMapper;
import com.letsiot.applications.service.SysPermissionResourcesService;
import com.letsiot.common.data.IdUtil;

@Service
public class SysPermissionResourcesServiceImpl implements SysPermissionResourcesService {

    @Autowired
    private SysPermissionResourcesMapper sysPermissionResourcesMapper;

    @Override
    public int save(SysPermissionResources entity) {
        if (entity.getId() == null) {
            entity.setId(IdUtil.getId());
        }
        return sysPermissionResourcesMapper.insertSelective(entity);
    }

    @Override
    public int delete(Long id) {
        return sysPermissionResourcesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(SysPermissionResources entity) {
        return sysPermissionResourcesMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public SysPermissionResources findById(Long id) {
        return sysPermissionResourcesMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysPermissionResources> getAll() {
        return sysPermissionResourcesMapper.getAll();
    }
}
